namespace devtm.Aop.Emit
{
    using System;
    using Mono.Cecil.Cil;
    using devtm.Aop.Extensions;

    [Serializable]
    public class EmitVariableReferenceExpression : EmitExpression
    {


        public EmitVariableReferenceExpression()
        {

        }


        public EmitVariableReferenceExpression(VariableDefinition variable)
        {
            this.Variable = variable;
        }


        public VariableDefinition Variable { get; set; }


        public override void Compile(CilWorker gen)
        {

            string way = UserData["way"] as string;
            
            if (way == "set")
                gen.SetStockLocation(Variable);
            else
            {
                gen.GetStockLocation(Variable);
            }
        }
        

    }
}
